package cn.tedu.backend.portal.controller;

import cn.tedu.backend.portal.model.Volunteer;
import cn.tedu.backend.portal.service.IVolunteerService;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class VolunteerController {
    @Resource
    private IVolunteerService service;

    @RequestMapping("/volunteerlist")
    public PageInfo<Volunteer> list(Integer pageNum){
        //分页
        if (pageNum==null)
            pageNum=1;
        Integer pageSize=12;
        //添加翻页page参数   ↓↓↓↓↓↓↓↓
        PageInfo<Volunteer> pageInfo = service.getVolunteers(pageNum,pageSize);

        return pageInfo;

    }

    @RequestMapping("/deleteVolunById")
    public int deleteById(int id){
        return service.deleteById(id);
    }

}
